// Copyright (c) 2007 Robin Boerdijk. All rights reserved.
//
// This software is licensed under the terms of the Microsoft Reciprocal License as described 
// in the file LICENSE.txt, which you should have received as part of this distribution. The 
// license terms are also available at http://www.opensource.org/licenses/ms-rl.html.

#include "demo/MainWindow.h"
#include "demo/AboutBox.h"
#include "demo/Calculator.h"

namespace demo
{
	MainWindow::MainWindow()
		: wtk::ApplicationWindow(L"WTK Demo")
	{
		m_menuBar.FileMenu.Exit.OnSelect(this, &MainWindow::Exit);
		m_menuBar.ToolsMenu.Calculator.OnSelect(this, &MainWindow::ShowCalculator);
		m_menuBar.HelpMenu.About.OnSelect(this, &MainWindow::ShowAboutBox);
	}

	wtk::Menu &MainWindow::GetMenuBar()
	{
		return m_menuBar;
	}

	void MainWindow::Exit(wtk::MenuCommand *sender)
	{
		PostQuitMessage(0);
	}

	void MainWindow::ShowCalculator(wtk::MenuCommand *sender)
	{
		wtk::DialogWindow::RunModeless(new Calculator(this));
	}

	void MainWindow::ShowAboutBox(wtk::MenuCommand *sender)
	{
		AboutBox(this).RunModal();
	}
}
